package com.leadnews.controller;

import com.leadnews.pojo.Cartoon;
import com.leadnews.service.CartoonService;
import com.leadnews.vo.CartoonVo;
import com.leadnews.vo.CommentVo;
import com.leadnews.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping
@CrossOrigin(origins = "*",maxAge = 3600)
public class CartoonController {
    @Autowired
    CartoonService cartoonService;

    @PostMapping("/getcartoon")
    public ResponseResult getCartoon(@RequestParam("cartoonname") String name){
        return cartoonService.getCartoon(name);
    }
    @PostMapping("/getcartoonnum")
    public ResponseResult getCartoonNum(@RequestBody CartoonVo cartoonVo){
        return cartoonService.getCartoonNum(cartoonVo);
    }
    @PostMapping("/submitcomment")
    public ResponseResult submitcomment(@RequestBody CommentVo commentVo){
        return cartoonService.saveComment(commentVo);
    }

    @PostMapping("/findComment")
    public ResponseResult findComment(@RequestBody Map<String,String> map){
        return cartoonService.findComment(map);
    }
//    查询番剧
    @GetMapping("/findCartoon")
    public ResponseResult findCartoon(){
        return cartoonService.findCartoon();
    }
}
